package com.ych.controller;


import com.ych.beans.Message;
import com.ych.beans.Role;
import com.ych.service.RoleService;
import com.ych.util.logUtil.AddLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/sys")
public class RoleController {
    @Autowired
    RoleService service;

    @AddLog
    @GetMapping({"/role","/role/{pageNo}","/role/{pageNo}/{roleName}"})
    public Message selectRole(@PathVariable Integer pageNo, @PathVariable(required = false) String roleName){
        return service.selectRole(pageNo,roleName);
    }

    @AddLog
    @PostMapping("/role")
    public Message addRole(@RequestBody Role r){
        return service.addRole(r);
    }

    @AddLog
    @DeleteMapping("/role/{id}")
    public Message delete(@PathVariable Integer id){
        return service.deleteRole(id);
    }

}
